package chapetr04.Example14;

abstract class Animal{
    abstract void shout();
}
class Cat extends Animal{
    void shout(){
        System.out.println("喵喵...");
    }
}
class Dog extends Animal{
    void shout(){
        System.out.println("汪汪...");
    }
}


public class Example14 {
    public static void main(String[] args) {
        Animal an1 = new Cat();
        Animal an2 = new Dog();
        an1.shout();
        an2.shout();
    }
}
 +24 Example15.java  0 -> 100644
package chapetr04.Example15_17;
class Animal{
    void shout(){
        System.out.println("喵喵...");
    }
}

class Dog extends Animal{
   public void shout(){
        System.out.println("汪汪汪...");
    }
    public void eat(){
        System.out.println("吃骨头...");
    }
}

public class Example15 {
    public static void main(String[] args) {
        Dog dog= new Dog();
        Animal an = dog;
        an.shout();
//        an.eat();
    }
}
 +10 Example16.java  0 -> 100644
package chapetr04.Example15_17;

public class Example16 {
    public static void main(String[] args) {
        Animal an = new Dog();
        Dog dog =  (Dog) an;
        dog.shout();
        dog.eat();
    }
}
 +14 Example17.java  0 -> 100644
package chapetr04.Example15_17;

public class Example17 {
    public static void main(String[] args) {
      Animal a1 = new Dog();
        System.out.println("动物类 a1= new Dog():"+(a1 instanceof Animal));
        System.out.println("动物类 a1= new Dog():"+(a1 instanceof Dog));
        Animal a2 =new Animal();
        System.out.println("动物类 a2=new Dog():"+(a2 instanceof Animal));
        System.out.println("动物类 a2=new Dog():"+(a2 instanceof Dog));


    }
}
package chapetr04.Example14;

abstract class Animal{
    abstract void shout();
}
class Cat extends Animal{
    void shout(){
        System.out.println("喵喵...");
    }
}
class Dog extends Animal{
    void shout(){
        System.out.println("汪汪...");
    }
}


public class Example14 {
    public static void main(String[] args) {
        Animal an1 = new Cat();
        Animal an2 = new Dog();
        an1.shout();
        an2.shout();
    }
}
 +24 Example15.java  0 -> 100644
package chapetr04.Example15_17;
class Animal{
    void shout(){
        System.out.println("喵喵...");
    }
}

class Dog extends Animal{
   public void shout(){
        System.out.println("汪汪汪...");
    }
    public void eat(){
        System.out.println("吃骨头...");
    }
}

public class Example15 {
    public static void main(String[] args) {
        Dog dog= new Dog();
        Animal an = dog;
        an.shout();
//        an.eat();
    }
}
 +10 Example16.java  0 -> 100644
package chapetr04.Example15_17;

public class Example16 {
    public static void main(String[] args) {
        Animal an = new Dog();
        Dog dog =  (Dog) an;
        dog.shout();
        dog.eat();
    }
}
 +14 Example17.java  0 -> 100644
package chapetr04.Example15_17;

public class Example17 {
    public static void main(String[] args) {
      Animal a1 = new Dog();
        System.out.println("动物类 a1= new Dog():"+(a1 instanceof Animal));
        System.out.println("动物类 a1= new Dog():"+(a1 instanceof Dog));
        Animal a2 =new Animal();
        System.out.println("动物类 a2=new Dog():"+(a2 instanceof Animal));
        System.out.println("动物类 a2=new Dog():"+(a2 instanceof Dog));


    }
}

package chapetr04.Example14;

abstract class Animal{
    abstract void shout();
}
class Cat extends Animal{
    void shout(){
        System.out.println("喵喵...");
    }
}
class Dog extends Animal{
    void shout(){
        System.out.println("汪汪...");
    }
}


public class Example14 {
    public static void main(String[] args) {
        Animal an1 = new Cat();
        Animal an2 = new Dog();
        an1.shout();
        an2.shout();
    }
}
 +24 Example15.java  0 -> 100644
package chapetr04.Example15_17;
class Animal{
    void shout(){
        System.out.println("喵喵...");
    }
}

class Dog extends Animal{
   public void shout(){
        System.out.println("汪汪汪...");
    }
    public void eat(){
        System.out.println("吃骨头...");
    }
}

public class Example15 {
    public static void main(String[] args) {
        Dog dog= new Dog();
        Animal an = dog;
        an.shout();
//        an.eat();
    }
}
 +10 Example16.java  0 -> 100644
package chapetr04.Example15_17;

public class Example16 {
    public static void main(String[] args) {
        Animal an = new Dog();
        Dog dog =  (Dog) an;
        dog.shout();
        dog.eat();
    }
}
 +14 Example17.java  0 -> 100644
package chapetr04.Example15_17;

public class Example17 {
    public static void main(String[] args) {
      Animal a1 = new Dog();
        System.out.println("动物类 a1= new Dog():"+(a1 instanceof Animal));
        System.out.println("动物类 a1= new Dog():"+(a1 instanceof Dog));
        Animal a2 =new Animal();
        System.out.println("动物类 a2=new Dog():"+(a2 instanceof Animal));
        System.out.println("动物类 a2=new Dog():"+(a2 instanceof Dog));


    }
}



